package LuoGu;

import java.util.Arrays;
import java.util.Scanner;

public class P3799 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n];
        int[] a=new int[4];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        int tmp=(int)Math.pow(10,9)+7;
        int sum=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    for(int l=k+1;l<n;l++){
                        a[0]=arr[i];
                        a[1]=arr[j];
                        a[2]=arr[k];
                        a[3]=arr[l];
                        Arrays.sort(a);
                        if(a[0]+a[1]==a[2]&&a[0]+a[1]==a[3]){
                            sum++;
                        }
                    }
                }
            }
        }
        System.out.print(sum);



    }
}
